# Modified from doBench.mpl sent by Changbo
kernelopts(opaquemodules=false);
with(RegularChains):
with(ChainTools):
with(ConstructibleSetTools):
with(PolynomialIdeals):
with(ListTools):

# having a proc will the function exit if a error occurs
doBench := proc()
local R, rst_save_path, res, fic, t0, t1, t2, dec_K, dec_L;
global sys, vars, params;
    fic := getenv("BENCHFILE");
    rst_save_path := getenv("RST_SAVE_PATH");
    if fic=NULL then
        print("Shell variable BENCHFILE not set ...");
        `quit`(1);
    end if;
    
	read(fic);
    R := PolynomialRing(vars,convert(params,set));
	dec_K:=NULL;
    t0 := time();
    dec_K := Triangularize(sys, R);
    t1 := time()-t0;

	dec_L:=NULL;
    t0 := time();
    dec_L := Triangularize(sys, R, output=lazard);
    t2 := time()-t0;
	if rst_save_path <> NULL then
    	save dec_K, dec_L, rst_save_path;
    end if;
	return [t1,  t2];
end:

res := doBench():


print(res);

